﻿using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace EnterpriseWebsiteApi.Controllers
{
    [ApiController]
    [Route("api/admin/[controller]/[action]")]
    public class AdminBaseController:ControllerBase
    {
        public enum ResultType
        {
                /// <summary>
                /// 成功
                /// </summary>
                Success = 200,
                /// <summary>
                /// 失败
                /// </summary>
                Fail = 201,
                /// <summary>
                /// 错误
                /// </summary>
                Error = 500,
                /// <summary>
                /// 用户未登录
                /// </summary>
                UserNotLogin = 206
        }

        [ApiExplorerSettings(IgnoreApi = true)]
        public ActionResult Success(object data = null)
        {
            return  new JsonResult(new { resultCode = ResultType.Success, resultData = data });
        }

        [ApiExplorerSettings(IgnoreApi = true)]
        public IActionResult InternalServerError(Exception ex)
        {
            return new JsonResult(new { resultCode = ResultType.Error, resultData = ex.Message });
        }
    }
}
